package com.gg.cart.controller;

import com.gg.cart.service.CartService;
import com.gg.cart.service.impl.CartServiceImpl;
import com.gg.povos.CartFruitPovo;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "GetCartsByUidServlet", value = "/cart/GetCartsByUidServlet")
public class GetCartsByUidServlet extends HttpServlet {
    /*web层 依赖 service层*/

    private CartService cartService = new CartServiceImpl();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /*1.获取参数*/
        String uid =  request.getParameter("uid");
        /*调用查看当前用户购物车业务*/
        List<CartFruitPovo> cartpovos=cartService.getCartsByUid(uid);
        /*2.域中传值*/
        request.getSession().setAttribute("cartpovos", cartpovos);
        /*3.页面跳转*/
        response.sendRedirect("/fruit/showcart.jsp");
    }

}
